﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;

namespace TestWinAPI.任务管理
{
    public partial class 任务管理器 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                GetAllProceess();
        }

        private void GetAllProceess()
        {
            Process[] processes;//Get the list of current active  processes.
            processes = System.Diagnostics.Process.GetProcesses();

            List<ProcessTask> lstProcessTask = new List<ProcessTask>();
            foreach (Process item in processes)
            {
                lstProcessTask.Add(new ProcessTask()
                {
                    Name = item.ProcessName,
                    //Name = item.MainModule.ModuleName,
                    Cpu = "",
                    //Ram = (Convert.ToDouble(item.WorkingSet64) / 1024) + "KB",
                    //Location = item.MainModule.FileName
                });
            }
            this.GridView1.DataSource = lstProcessTask;
            this.GridView1.DataBind();
        }



    }

    public class ProcessTask
    {
        public string Name { get; set; }
        public string Cpu { get; set; }
        public string Ram { get; set; }
        public string Location { get; set; }
    }
}
